package com.example.klaraservice.vo;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : Glacialerisa
 * @date : 2023/5/28 14:29
 * @desc : 数据的包装
 */
@Data
public class R {
    /**
     * Integer code; //响应码
     * String message; //响应消息
     * boolean result; //响应结果
     */
    private Integer code;
    private String message;
    private boolean result;
    private Map<String, Object> data = new HashMap<>();
    public static R ok(){
        R r = new R();
        r.setCode(200);
        r.setMessage("success");
        r.setResult(true);
        return r;
    }

    public static R error(){
        R r = new R();
        r.setCode(-1);
        r.setMessage("fail");
        r.setResult(false);
        return r;
    }
    public R data(String key, Object value){
        this.data.put(key, value);
        return this;
    }
}
